<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/11/30
 * Time: 18:21
 */
require_once(dirname(__FILE__) . '/../../inc/config.inc.php');
require_once(dirname(__FILE__) . '/../../function.php');
IsModelPriv('member');


$field=isset($_POST['field']) ? $_POST['field'] : [];

$manageid = isset($field['id']) ? intval($field['id']) : 0;   //用户的身份
$fee = isset($field['fee']) ? intval($field['fee']) : 0;   //用户的身份
$date = isset($field['date']) ? htmlspecialchars($field['date']) : '';   //用户的身份
$moshi = isset($field['moshi']) ? htmlspecialchars($field['moshi']) : "";   //用户的身份
$remark = isset($field['remark']) ? htmlspecialchars($field['remark']) : "";   //用户的身份
$action = isset($_POST['action']) ? htmlspecialchars($_POST['action']) : "";   //用户的身份

$post_time= empty($date) ?   time() : strtotime($date) ;

if ($action == 'add') {
    if($fee<=0 ){
        $jssdk->return_json_body(['code'=>-1,'msg'=>'积分输入不正确，请重新输入']);
    }
    if($manageid==0 ){
        $jssdk->return_json_body(['code'=>-2,'msg'=>'非法操作，工程师不正确']);
    }
    if($moshi=="add" || $moshi=="move" ){

    }else{
        $jssdk->return_json_body(['code'=>-3,'msg'=>'非法操作，模式不正确']);
    }
    if($remark=="" ){
        $jssdk->return_json_body(['code'=>-4,'msg'=>'非法操作，请输入备注']);
    }


    //增加奖励计划
    if($moshi=="add"){
        $dosql->ExecNoneQuery("update  `#@__user` set fee=fee+'$fee' where id='$manageid' ");
    }
    if($moshi=="move"){
        $dosql->ExecNoneQuery("update  `#@__user` set fee=fee-'$fee' where id='$manageid' ");
    }

    $remark="管理员后台操作 操作原因：".$remark;

    //写入 奖励操作记录
    $dosql->ExecNoneQuery("insert into `#@__fee_log`(`type`,orderid,op,op_time,jindu,manageid,remark,fee,task) values ('admin','0','$moshi','$post_time','100','$manageid','$remark','$fee','0')");


    $jssdk->return_json_body(['code'=>0,'msg'=>'操作成功']);
}
